﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class KeyUnit_KeyUnitView : System.Web.UI.Page
{

    public String Str1 = "";
    public String Str2 = "";
    public String Str3 = "";
    public String Str4 = "";
    public String Str5 = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = string.Empty;
            try
            {
                id = Request.Params["id"];

                //id = "cfecb85d-6674-44c6-80b6-324635b1042d";
            }
            catch
            {
                Response.Write("<script language=javascript>alert('错误:参数错误。')</script>");
                return;
            }

            //string id = "6e7fd43c-185b-4a9e-9fcf-06eb4ac2b77f"; //重点单位id

            string sql = "select KeyUnitName,KeyUnitTypeID,KeyUnitInfo,PerformanceState,PerformanceInfo,writetime from Performance where PerformanceID='" + id + "'";
            DBCls db = new DBCls();
            DataTable dt = db.QueryDataTable(sql, "Performance");
            if (dt.Rows.Count > 0)
            {
                this.lblName.Text = dt.Rows[0][0].ToString();   //名称
                this.lblTime.Text = dt.Rows[0][5].ToString();   //时间
                string type = dt.Rows[0][1].ToString(); //类型

                DataTable dt2 = db.QueryDataTable("select KeyUnitTypeName from KeyUnitType where KeyUnitTypeID='" + type + "' ", "a");
                if (dt2.Rows.Count > 0)
                    lblType.Text = dt2.Rows[0][0].ToString();

                lblInfo.Text = dt.Rows[0][2].ToString();//信息
                string state = dt.Rows[0][3].ToString();//完成
                if (state == rblState.Items[0].Value)
                    rblState.Items[0].Selected = true;
                else
                    rblState.Items[1].Selected = true;
                lblWancheng.Text = dt.Rows[0][4].ToString();

                //概貌
                string sqlgm = "select PictureUrl,PictureDescript,PictureType from PerformancePic where PerformanceID='" + id + "'and PictureType='单位概貌' ";
                DataTable dtgm = db.QueryDataTable(sqlgm, "gn");
                if (dtgm.Rows.Count > 0)
                {
                    Str1 = dtgm.Rows[0][2].ToString().Trim();
                    dlDWGM.DataSource = dtgm;
                    dlDWGM.DataBind();
                }
                else
                {
                    DataRow dr = dtgm.NewRow();
                    dr[0] = "";
                    dr[1] = "没有图片";
                    dtgm.Rows.Add(dr);
                    dlDWGM.DataSource = dtgm;
                    dlDWGM.DataBind();
                }
                //检查和整改火灾隐患
                string sqlbs = "select PictureUrl,PictureDescript,PictureType from PerformancePic where PerformanceID='" + id + "'and PictureType in ('检查消除火灾隐患能力','检查和整改火灾隐患','一懂三会') ";
                DataTable dtbs = db.QueryDataTable(sqlbs, "bs");
                if (dtbs.Rows.Count > 0)
                {
                    Str2 = dtbs.Rows[0][2].ToString().Trim();
                    dlBSZT.DataSource = dtbs;
                    dlBSZT.DataBind();
                }
                else
                {
                    DataRow dr = dtbs.NewRow();
                    dr[0] = "";
                    dr[1] = "没有图片";
                    dtbs.Rows.Add(dr);
                    dlBSZT.DataSource = dtbs;
                    dlBSZT.DataBind();
                }

                //扑救初期火灾
                string sqljy = "select PictureUrl,PictureDescript,PictureType from PerformancePic where PerformanceID='" + id + "'and PictureType in ('组织扑救初起火灾能力','扑救初期火灾','消防标识') ";
                DataTable dtjy = db.QueryDataTable(sqljy, "bs");
                if (dtjy.Rows.Count > 0)
                {
                    Str3 = dtjy.Rows[0][2].ToString().Trim();
                    this.dlJYPX.DataSource = dtjy;
                    dlJYPX.DataBind();
                }
                else
                {
                    DataRow dr = dtjy.NewRow();
                    dr[0] = "";
                    dr[1] = "没有图片";
                    dtjy.Rows.Add(dr);
                    dlJYPX.DataSource = dtjy;
                    dlJYPX.DataBind();
                }

                //组织引导人员疏散逃生
                string sqlll = "select PictureUrl,PictureDescript,PictureType from PerformancePic where PerformanceID='" + id + "'and PictureType in ('组织人员疏散逃生能力','组织引导人员疏散逃生','消防教育培训') ";
                DataTable dtll = db.QueryDataTable(sqlll, "ll");
                if (dtll.Rows.Count > 0)
                {
                    Str4 = dtll.Rows[0][2].ToString().Trim();
                    dlLLYL.DataSource = dtll;
                    dlLLYL.DataBind();
                }
                else
                {
                    DataRow dr = dtll.NewRow();
                    dr[0] = "";
                    dr[1] = "没有图片";
                    dtll.Rows.Add(dr);
                    dlLLYL.DataSource = dtll;
                    dlLLYL.DataBind();
                }
                //消防安全知识宣传教育培训
                string sqlws = "select PictureUrl,PictureDescript,PictureType from PerformancePic where PerformanceID='" + id + "'and PictureType in ('消防宣传教育培训能力','消防安全知识宣传教育培训') ";
                DataTable dtws = db.QueryDataTable(sqlws, "ll");
                if (dtws.Rows.Count > 0)
                {
                    Str5 = dtws.Rows[0][2].ToString().Trim();
                    dlWSDA.DataSource = dtws;
                    dlWSDA.DataBind();
                }
                else
                {
                    DataRow dr;
                    //dtws.Columns.Add("PictureUrl", typeof(string));    //url
                    //dtws.Columns.Add("PictureDescript", typeof(string));   //说明
                    dr = dtws.NewRow();
                    dr[0] = "";
                    dr[1] = "没有图片";

                    dtws.Rows.Add(dr);

                    dlWSDA.DataSource = dtws;
                    dlWSDA.DataBind();
                }
            }

        }
    }
}
